<%@ page import="njust.edu.entity.Dish" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="njust.edu.web.Page" %>
<%@ page import="njust.edu.web.Cart" %><%--
  Created by IntelliJ IDEA.
  User: 陈
  Date: 2021/9/17
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>客户点餐界面</title>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script>
        function addToCart(d){
                $.post("CartController?method=addToCart&id="+d,function(){
                    alert("加入成功");
                });
        }
    </script>
    <style>
        /* Custom Styles */


        .container{
            position:absolute;
            width:1500px;
            height:1100px;
            left: 520px;
            top: 80px;
            align-self: center;/*
	  background-color: lightgreen; */
        }
        #navbar-example{
            margin-left: 40px;
            position:relative;
            width:260px;
            height:550px;
            top:0px;
            align-self: center;
            padding: 20px;
            border-style: none;
            outline: none;
        }
        #menu{
            position:relative;
            width:1160px;
            height:1100px;
            top:0px;
            padding: 0px;
            border-style: none;
            outline: none;
            overflow:auto;
            float: left;
        }
        .dish{
            position:relative;
            opacity: 1.0;
            width:550px;
            height:250px;
            left:0px;
            background-color:  #FDF5E6;
            padding: 10px;
            border-style: none;
            outline: none;
            overflow:auto;
            float: left;
            margin: 5px;
        }
        .type{
            background-color: 	#FFEBCD;
            opacity: 0.8;
            position:relative;
            width:1150px;
            /*height:500px;*/
            top:0px;
            margin-bottom: 30px;
            /* 	  background-color: wheat; */
            padding: 10px;
            border-style: none;
            outline: none;
            overflow:auto;
            float: left;
            border-width: 5px;
        }
        .type_id{
            margin-bottom: 5px;
            position:relative;
            width:160px;
            height:60px;
            top:0px;
            background-color: #080808;
            text-align: center;
            display: block;
            font-size: x-large;
            color: white;
            border-style: none;
            outline: none;
            border-radius: 10px;
        }

        .header {
            font-size: 140%;
            opacity: 0.8;
            position: absolute;
            top: 0;
            width: 100%;
            height: 80px;
        }
        .header ul {
            list-style-type: none;
            background-color: #333;
            margin: 0;
            padding: 0;
            overflow: hidden;
            width: 100%;
            height: 80px;
        }

        .header li {
            float: left;
            height: 80px;
            width: 200px;
        }

        .header li a {
            display: block;
            color: white;
            text-align: center;
            padding: 30px;
            text-decoration: none;
            height: 80px;
        }

        .header li a:hover:not(.active) {
            background-color: 	#808080;
        }

        /*    ul.nav-tabs{
                width: 140px;
                margin-top: 20px;
                border-radius: 4px;
                box-shadow: 0 1px 4px rgba(0, 0, 0, 0.067);
            } */

        ul.nav-tabs li.active a, ul.nav-tabs li.active a:hover{
            color: black;
            background: #FFEBCD;
        }

    </style>
    <style>
        a:link {text-decoration:none;}
        a:visited {text-decoration:none;}
        a:hover {text-decoration:none;}
        a:active {text-decoration:none;}
        p{
            font-family:georgia;
            font-weight: 300;
        }
        .dish_img{
            position:relative;
            width:240px;
            height:200px;
            top: 10px;
            overflow: auto;
            float: left;
            /* 	background-color: wheat; */
        }
        .dish_name{
            color: black;
            position:relative;
            width:280px;
            height:70px;
            padding-top: 14px;
            left: 20px;
            align-self: center;
            overflow: auto;
            /* 	background-color: yellow; */
            font-size: 210%;
            float: left;
            padding-left: 10px;
        }
        .dish_price{
            position:relative;
            width:200px;
            height:50px;
            align-self: center;
            overflow: auto;
            left: 0px;
            /* 	background-color: darkorange; */
            padding-left: 15px;
            padding-top: 5px;
            font-size: 160%;
            float: left;
        }
        .dish_name p{
            font-weight: 400 ;
        }
        .dish_price p{
            font-weight: 400 ;
        }
        .change_quantity p{
            font-weight: 600;
        }
        .dish_inf{
            position:relative;
            width:280px;
            height:150px;
            left: 20px;
            overflow: auto;
            float: left;
            /* 	background-color: lightblue; */
        }
        .dish_num{
            position:relative;
            width:240px;
            height:70px;
            left: 40px;
            top: 25px;
            padding-left: 30px;
            padding-top: 10px;
            overflow: auto;
            float: left;
            /* 	background-color: wheat; */
        }
        a.change_quantity{
            position:relative;
            width:180px;
            height:55px;
            overflow: auto;
            float: left;
            display: block;
            padding-top: 10px;
            margin-left: 5px;
            margin-right: 5px;
            text-align: center;
            background-color: coral;
            color: black;
            border-radius: 25px;
            border-style: solid;
            border-width: 3px;
            font-size: 140%;
        }
        .dish_num a:hover:not(.active) {
            background-color: orangered;
        }
    </style>
</head>
<body data-spy="scroll" data-target="#myScrollspy">
<div class = "backGround" style="position: relative;">
    <img src = "../img/book.jpg" width="2402px" height="1202px">
    <div class="header">
        <ul>
            <li><a href="BookController?method=allDishList">菜单</a></li>
            <li><a href="CartController?method=toCartUI">购物车</a></li>
            <li><a href="TradeController?method=toTradeAllUI">订单</a></li>
            <li style="float: right"><a href="index.jsp" ><p>退出登录</p></a></li>
        </ul>
    </div>
    <div class="container">
        <nav id="navbar-example" class="navbar navbar-static" role="navigation" style="float: left;" >

            <div class=" collapse navbar-collapse bs-js-navbar-scrollspy" id="myScrollspy" style="  padding-left: 70px; opacity: 0.7;">
                <ul class="nav nav-tabs nav-stacked" data-spy="affix" data-offset-top="125"  style="border-style: none;outline-style: none;">
                    <li><a class ="active type_id"  href="#section-1">主食</a></li>
                    <li><a class = "type_id" href="#section-2"><p style="text-align: center;">凉菜</p></a></li>
                    <li><a class = "type_id" href="#section-3"><p style="text-align: center;">汤羹</p></a></li>
                    <li><a class = "type_id" href="#section-4"><p style="text-align: center;">开胃菜</p></a></li>
                    <li><a class = "type_id" href="#section-5"><p style="text-align: center;">私房菜</p></a></li>
                    <li><a class = "type_id" href="#section-6"><p style="text-align: center;">酒水</p></a></li>
                    <li><a class = "type_id" href="#section-7"><p style="text-align: center;">甜点</p></a></li>
                </ul>
            </div>
        </nav>
        <div  id ="menu" class="col-xs-9" data-spy="scroll" data-target="#navbar-example" data-offset="0" >
            <div id="section-1" class="type">
                <%
                    List<Dish> dish_list = (List<Dish>) request.getAttribute("dishList");
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==1){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                            }
                            else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                    }
                %>
            </div>
            <hr>
            <div id="section-2" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==2){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                                }
                                else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
            <hr />
            <div id="section-3" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==3){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
            <hr />
            <div id="section-4" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==4){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                            }
                            else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
            <hr />
            <div id="section-5" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==5){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                            }
                            else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
            <hr />
            <div id="section-6" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==6){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                            }
                            else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
            <hr />
            <div id="section-7" class="type">
                <%
                    for(Dish dish:dish_list){
                        if (dish.getType_id()==7){
                %>
                <div class = "dish">
                    <div class = "dish_img">
                        <img src="../img/<%=dish.getPicture()%>" width="240px" height="200px">
                    </div>
                    <div class = "dish_name"><p><%=dish.getName()%></p></div>
                    <div class = "dish_inf">
                        <div class = "dish_price"><p><%=dish.getPrice()%>元</p></div>
                        <div class = "dish_num">
                            <%
                                if (dish.getStock()>=1){
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="addToCart(<%=dish.getId()%>)"><p>加入购物车</p></a>
                            <%
                            }
                            else {
                            %>
                            <a href="#" class = "change_quantity" id = "reduce_quantity" onclick="return false" style="background-color: #606060 ;color: white"><p>库存不足</p></a>
                            <%
                                }
                            %>
                        </div>
                    </div>
                </div>
                <%      }
                }
                %>
            </div>
        </div>
    </div>
</div>
</body>
</html>
